class Solution {
public:
    bool isPalindrome(ListNode* head) {
        vector<int> v;
        while(head) {
            v.emplace_back(head->val);
            head = head->next;
        }
        int l = 0, s = v.size() - 1;
        while(l < s) if (v[l++] != v[s--]) return false;
        return true;
    }
};
